﻿using System.Security.Cryptography;
using System;
using System.Threading;
using Scheduler;

using static System.Net.Mime.MediaTypeNames;

namespace UnitTesting.Engine
{
    public class TestingContext : Context
    {
        public long TestingTime { get; set; }
        public long CycleTime { get; set; }
     
        private ThreadLocal<int> _index = new ThreadLocal<int>(() => -1);

        public object LotResult { get; set; }
        public object DUT { get; set; }



        public TestingContext( )
        {
            GetNextPassDut = () =>
            {
                return DUT;
            };
        }

        public override object Next(object workerId)
        {
            var st = (int)workerId;
            _index.Value++;
            var index = _index.Value;

            Console.WriteLine($"workerId:{workerId}next:{index}");
            //System.Threading.Thread.Sleep(3000);
            if ((int)workerId == 4)
            {
                
            }
            return index;

 
        }

        public void SetCurrentHandled(int st, int index)
        {
            _index.Value = index;
        }

        public override bool ShouldSkipWorker(object workId)
        {
            return false;
          
        }
    }
}